home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 8: LINUX Games
/
Linux Cubed Series 8 - LINUX Games.iso
/
games
/
x11
/
strategy
/
xpuzzles.3
/
xpuzzles
/
xpuzzles-5.3.1
/
xoct
/
rngs.c
< prev
next >
Wrap
Text File
|
1996-02-05
|
593b
|
28 lines
/*
Dr. Park's algorithm published in the Oct. '88 ACM
"Random Number Generators: Good Ones Are Hard To Find"
His version available at ftp://cs.wm.edu/pub/rngs.tar
Present form by many authors.
*/
static int Seed = 1; /* This is required to be 32 bits long */
/*
* Given an integer, this routine initializes the RNG seed.
*/
void SetRNG(s)
long s;
{
Seed = (int) s;
}
/*
* Returns an integer between 0 and 2147483647, inclusive.
*/
long LongRNG()
{
if ((Seed = Seed % 44488 * 48271 - Seed / 44488 * 3399) < 0)
Seed += 2147483647;
return (long) (Seed - 1);
}